Bite 247. Mocking a standard library function
Login and get coding
Note this is a Test Bite and uses Python 3.7 and MutPy 0.6.1
In this Bite you will mock out a function of the standard library, more specifically random.sample.
We wrote a small generator that produces hex colors. We also provided a fixture to initialize the generator so you can just call
next(gen)to get the next hex value.Use
unittest.mock'spatchto mock out the call tosample. It might be a bit tricky, but once you get this one down you possess a valuable testing skill!Have fun and keep calm and test with
pytest!
98 out of 106 users completed this Bite.
Will you be the 99th person to crack this Bite?
Resolution time: ~89 min. (avg. submissions of 5-240 min.)
Our community rates this Bite 7.7 on a 1-10 difficulty scale.
» Up for a challenge? 💪